package com.alibaba.citrus.cr.price.ability.functions.factory.price;

import com.alibaba.citrus.cr.price.ability.functions.entity.price.PriceRecordEntity;
import com.alibaba.lattice2.epoch.sdk.model.Result;
import com.epoch.app.crpricecenter.sdo.PriceRecordSDO;

/**
 * @author: qiaojiange
 * @create: 2021/09/16
 * @Description 价格记录工厂
 */
public class PriceRecordFactory extends PriceBaseFactory {

    /**
     * 创建价格记录
     * @param recordId 价格记录 id
     * @return
     */
    public static PriceRecordEntity create(String recordId) {
        Result<PriceRecordSDO> recordSDOResult = queryRepository.queryPriceRecord(recordId);
        PriceRecordEntity recordEntity = new PriceRecordEntity();
        if (recordSDOResult.isSuccess()) {
            recordEntity = PriceRecordEntity.of(recordSDOResult.getResult());
        }
        return recordEntity;
    }
}
